import { bus } from "/utils/core";
import request from "/utils/omsRequest";
import { moment } from "/utils/core";

Component({
  mixins: [],
  data: {
    progress: [],
    title: ""
  },
  props: {
    show: false,
    onClose: () => { }
  },
  didMount() {
    bus.subscribe("onContractProgress", (contract) => {
      this.setData({
        title: contract.merchantName + "的合同"
      });
      request({
        url: "/ajax/operationalRecord/list",
        data: {
          businessId: contract.id,
          operationalType: "CONTRACT"
        }
      }).then(res => {
        res.voList.map(item => {
          item.operationalDate = moment(item.operationalDate).format('YYYY-MM-DD HH:mm:ss');
        })
        this.setData({
          progress: res.voList
        });
      })
    });
  },
  didUpdate() { },
  didUnmount() {
    bus.remove("onContractProgress")
  },
  methods: {
    hideModal(e) {
      this.props.onClose(e);
    }
  },
});
